package com.xzx;

import jakarta.jms.Connection;
import jakarta.jms.Session;
import org.apache.activemq.ActiveMQConnectionFactory;

/**
 *
 * @author xinzhixuan
 * @version 1.0
 * @date 2025/9/10 14:48
 */
public final class AmqUtil {

    public static Connection getConnection() throws Exception {
        Connection connection = new ActiveMQConnectionFactory("admin", "admin", "tcp://localhost:61616").createConnection();
        connection.start();
        return connection;
    }

    public static void closeConnection(Connection connection) throws Exception {
        if (connection == null) {
            connection.close();
        }
    }

}
